// get/set width of navbar and make it resizeable
if ($.cookie("navbarwidth")){
	var navbarwidth = $.cookie("navbarwidth");
}else {
	$.cookie("navbarwidth", "150", {expires: 180, path: '/'});
	var navbarwidth = "150";
}

if ($.cookie("shownavbar")){
	var shownavbar = $.cookie("shownavbar");
}else{
	$.cookie("shownavbar", "true", {expires: 180, path: '/'});
	var shownavbar = "true";
}

$(document).ready(function(){
	$("#handleDiv").bind("dblclick", function(e){
		$("#ms-navframe").toggle(50,function(){
			var shownavbar = $.cookie("shownavbar");
			if(shownavbar == "false"){
				$.cookie("shownavbar", "true", {expires: 180, path: '/'});
				if ($("#ctl00_PlaceHolderPageImage_ctl00")) {
					$("#ctl00_PlaceHolderPageImage_ctl00").show();
				}
				$("#handleDiv").hide();
				var shownavbar = "true";
			}else{
				$.cookie("shownavbar", "false", {expires: 180, path: '/'});
				if ($("#ctl00_PlaceHolderPageImage_ctl00")) {
					$("#ctl00_PlaceHolderPageImage_ctl00").hide();
				}
				$("#handleDiv").show();
				var shownavbar = "false";
			}
		}); 
	});
	
	$("#resizeBox").resizable({
		minWidth: "150",
		handles: "e",
		resize: function(ev,ui){
			$("#resizeBox").height("100%");
			$("#resizeBox").css("padding-bottom","50px");
		},
		stop: function(ev,ui){
			$.cookie("navbarwidth", $(this).width(), {expires: 180, path: '/'});
		}
	});
	
	$(".ui-resizable-handle").bind("dblclick", function(e){
		$("#ms-navframe").toggle(100,function(){
			var shownavbar = $.cookie("shownavbar");
			if(shownavbar == "false"){
				$.cookie("shownavbar", "true", {expires: 180, path: '/'});
				if ($("#ctl00_PlaceHolderPageImage_ctl00")) {
					$("#ctl00_PlaceHolderPageImage_ctl00").show();
				}
				$("#handleDiv").hide();
				var shownavbar = "true";
			}else{
				$.cookie("shownavbar", "false", {expires: 180, path: '/'});
				if ($("#ctl00_PlaceHolderPageImage_ctl00")) {
					$("#ctl00_PlaceHolderPageImage_ctl00").hide();
				}
				$("#handleDiv").show();
				var shownavbar = "false";
			}
		}); 
	});

	$(".ui-resizable-handle").attr("title","Double-click to toggle sidebar");
	var middleWin = $(window).height()/2;
	$("#handleIMG").css("top",middleWin+"px");
});